﻿using System;
using System.IO;
using Presentation;

namespace Infrastructure
{
    public class TxtLogger : ILogger
    {
        private readonly string logFile;

        public TxtLogger(string logFile = "log.txt")
        {
            this.logFile = logFile;
            var file = File.Create(logFile);
            file.Close();
        }

        public void Write(string message)
        {
            var file = new StreamWriter(logFile, true);
            file.WriteLine(DateTime.Now.ToString() + ": " + message);
            file.Close();
        }

        public string Read()
        {
            var file = new StreamReader(logFile);
            var content = file.ReadToEnd();
            file.Close();
            return content;
        }
    }
}
